package org.example.Soution002;

public class findTarget {
    public static void main(String[] args) {
        int[] res=new int[]{6,7,0,1,2,4,5};
        findTarget target=new findTarget();
        System.out.println(target.search(res,3));
    }

    public int search(int[] nums, int target) {
        int start=0,end=nums.length-1;
        while(start<=end){
            int mid=(start+end)/2;
            if(nums[mid]==target){
                return mid;
            }else if((nums[start]<nums[mid]&&target>=nums[start]&&target<=nums[mid])||(nums[start]>nums[mid]&&(target>=nums[start]||target<=nums[mid]))){
                end=mid-1;
            }else{
                start=mid+1;
            }
        }
        return -1;
    }
}
